# -*- coding: utf-8 -*-

# 这个文件的代码是对人人网进行操作
import scrapy


class LoginSpider(scrapy.Spider):
    name = 'login'
    allowed_domains = ['http://www.renren.com/']
    start_urls = ['http://http://www.renren.com//']

    #通过重写这个start_requests这个函数,让请求的时候,进入了登录状态
    def start_requests(self):
        url='http://www.renren.com/PLogin.do'
        data={
        'email':'18934084265',
        'password':'litianbao8569378'
    }
        request=scrapy.FormRequest(url,formdata=data,callback=self.parse_page)
        yield request

    def parse_page(self,response):
        with open('renren.html','w',encoding='utf-8') as fq:
            fq.write(response.text)
